#!/usr/bin/perl
#
# Test the Counter cache module
#

use Counter::Cache;

$cache = Counter::Cache->new(\&identity, 60);
print "Static procedure\n";
print "Five is ", $cache->get(5), "\n";
print "Seven is ", $cache->get(7), "\n";

print "Incrementing function\n";
$cache = Counter::Cache->new(\&increment, 60);
print "First is ", $cache->get(1), "\n";
print "Second is ", $cache->get(1), "\n";
print "Turn off caching\n";
$cache->timeout(0);
print "First is ", $cache->get(1), "\n";
print "Second is ", $cache->get(1), "\n";

$cache->statistics();

sub identity {

    my $arg = shift;
    return $arg;

}

sub increment {
    my $arg = shift;
    # global incrementcount
    ++ $increment;
    return $increment;
}




